import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class ExpenseManager {
    private List<Transaction> incomes;
    private List<Transaction> expenses;

    public ExpenseManager() {
        incomes = new ArrayList<>();
        expenses = new ArrayList<>();
    }//添加功能：预算管理、月度统计

    public void addIncome(Date date, double amount, String category, String remark) {
        if (amount <= 0) {
            throw new IllegalArgumentException("收入金额必须为正数");
        }
        incomes.add(new Transaction(date, amount, category, remark));
    }

    public void addExpense(Date date, double amount, String category, String remark) {
        if (amount <= 0) {
            throw new IllegalArgumentException("支出金额必须为正数");
        }
        expenses.add(new Transaction(date, amount, category, remark));
    }

    public double getTotalIncome() {
        return incomes.stream().mapToDouble(Transaction::getAmount).sum();
    }

    public double getTotalExpense() {
        return expenses.stream().mapToDouble(Transaction::getAmount).sum();
    }

    public List<Transaction> getIncomes() {
        return incomes;
    }

    public List<Transaction> getExpenses() {
        return expenses;
    }
}